﻿/* Tag class. */
var Tag = function () {

};
Tag.prototype.InsertTag = function (name, slug, parent, des, taxonomy) {
    var jsonStr = "{Name:'" + name + "',Slug:'" + slug + "',ParentId:" + parent + ",Des:'" + des + "',Taxonomy:'" + taxonomy + "'}";
    $.ajax({
        type: "POST",
        url: "/Admin/WS/UpdateTag.asmx/InsertCategory",
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        data: jsonStr,
        success: function (msg) {
            if (msg.d == -2) {
                alert('A term with the name provided already exists');
            }
            if (msg.d == -1) {
                alert('Error1!');
            }
            //var $ctrl = $('<input/>').attr({ type: 'button', name: 'btn', value: 'Button', id: 'btn1' }).addClass("btn");
            //var $ctrl2 = $('<input/>').attr({ type: 'button', name: 'btn', value: 'Button', id: 'btn2' }).addClass("btn");
            //$("#form-field1").append($ctrl);
            //$("#form-field1").append($ctrl2);
            return true;
        },
        error: function () {
            alert("Error2!");
            return false;
        }
    });

};
Tag.prototype.DeleteTag = function (id) {
    var jsonStr = "{Id:" + id + "}";
    $.ajax({
        type: "POST",
        url: "/Admin/WS/UpdateTag.asmx/DeleteTag",
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        data: jsonStr,
        success: function (msg) {
            return msg.d;
        },
        error: function () {
            return -1;
        }
    });

};
/* Usage. */
